<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/9
 * Time: 15:12
 */

class Paymodel extends CI_Model{
    var $conn;

    public function __construct()
    {
        parent::__construct();
        $this->conn = $this->load->database('local', TRUE);
    }

    /**
     * 获取付款信息
     * @param $openid
     * @return mixed
     */
    public  function getPayLog($openid){
        $sql = "select fee,attach,createtime from qiming.qmorder WHERE openid='$openid' order by createtime";
        $query = $this->conn->query($sql);
        return $query->result_array();
    }

    /**
     * 添加套餐刷新次数
     * @param $fee
     * @param $openid
     */
    public function addPayCount($openid,$fee){
        $count=0;
        if($fee==1980){
            $count=1000;
        }
        if($fee==3980){
            $count=10000;
        }
        $sql = "UPDATE qiming.testmember SET havecount=havecount+$count WHERE flag = 1 and openid='$openid'";
        $this->conn->query($sql);
    }
}